#ifndef _NAMEVALUECOLLECTION_HPP_
#define _NAMEVALUECOLLECTION_HPP_

#include "jhdefs.hpp"
#include "net/ListMap.hpp"

NET_NAMESPACE_BEGIN

class CNameValueCollection
{
public:
	typedef TListMap<std::string, std::string> HeaderMap;
	typedef HeaderMap::Iterator Iterator;
	typedef HeaderMap::ConstIterator ConstIterator;

	CNameValueCollection();
	CNameValueCollection(const CNameValueCollection& nvc);
	virtual ~CNameValueCollection();
	CNameValueCollection& operator = (const CNameValueCollection& nvc);

	void swap(CNameValueCollection& nvc);

	const std::string& operator [] (const std::string& name) const;

	void set(const std::string& name, const std::string& value);	
	void add(const std::string& name, const std::string& value);
	const std::string& get(const std::string& name) const;
	const std::string& get(const std::string& name, const std::string& defaultValue) const;
	bool has(const std::string& name) const;
	ConstIterator find(const std::string& name) const;
	ConstIterator begin() const;
	ConstIterator end() const;
	bool empty() const;
	std::size_t size() const;
	void erase(const std::string& name);
	void clear();

private:
	HeaderMap m_map;
};

//
// inlines
//
inline void swap(CNameValueCollection& nvc1, CNameValueCollection& nvc2)
{
	nvc1.swap(nvc2);
}


NET_NAMESPACE_END

#endif
